/*
 * @lc app=leetcode.cn id=450 lang=golang
 *
 * [450] 删除二叉搜索树中的节点
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
//deleteNode 返回子树根节点
func deleteNode(root *TreeNode, key int) *TreeNode {
	//查找
	//查到找后，判断是否单子树节点
	//双子树节点

	if root == nil {
		return nil
	}

	if key < root.Val {
		root.Left = deleteNode(root.Left, key)
		return root
	}

	if key > root.Val {
		root.Right = deleteNode(root.Right, key)
		return root
	}

	//到这里意味着root.Value==key
	if root.Left == nil {
		new_root := root.Right
		root.Right = nil
		return new_root
	}

	if root.Right == nil {
		new_root := root.Left
		root.Left = nil
		return new_root
	}

	successor:=minimum(root.Right)
	successor.Left = root.Left
	successor.Right = 
}

func remove_min(root *TreeNode))*TreeNode{

}

func minimum(root *TreeNode)*TreeNode{
	for root.Left!=nil{
		root = root.Left
	}

	return root	
}

// @lc code=end

